package com.indeep.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.indeep.user.emun.UserStatusEnum;
import com.indeep.user.mapper.UserInfoMapper;
import com.indeep.user.mapper.po.UserInfoPO;
import com.indeep.user.service.IUserInfoService;
import com.indeep.user.service.base.BaseServiceImpl;
import com.indeep.user.vo.UserInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Service("iUserInfoService")
public class IUserInfoServiceImpl extends BaseServiceImpl<UserInfoMapper, UserInfoPO> implements IUserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public List<UserInfoVO> queryAllUserStatus() {
        QueryWrapper<UserInfoPO> userInfoPOQueryWrapper = new QueryWrapper<>();
        userInfoPOQueryWrapper.ne("status", UserStatusEnum.USER_CANCELLATION.getCode());
        List<UserInfoPO> userInfoPOS = userInfoMapper.selectList(userInfoPOQueryWrapper);
        return userInfoPOS.stream().map(a->{
            UserInfoVO userInfoVO = new UserInfoVO();
            BeanUtils.copyProperties(a,userInfoVO);
            return userInfoVO;
        }).collect(Collectors.toList());

    }
}
